package com.atguigu.service;

import com.atguigu.DAO.impl.UserDAO;
import com.atguigu.DAO.impl.UserDaoImple;
import com.atguigu.pojo.User;

public class UserServiceImpl implements UserService{

    private UserDAO userDAO=new UserDaoImple();

    @Override
    public void registUser(User user) {
        userDAO.saveUser(user);
    }

    @Override
    public User login(User user) {
       return userDAO.queryUserByUsernameandpassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
       if(userDAO.queryUserByUsername(username)==null){
           //等于null说明没查到，没查到表示可用
           return false;
       }
       return true;
    }
}
